<%@ page language="java" import="java.util.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 <html >
<head>
<script src='<%=basePath%>common/uploadify/jquery-1.5.1.min.js'></script>  
<script src='<%=basePath%>common/uploadify32/swfobject.js'></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>common/uploadify32/uploadify.css" />

<script src='<%=basePath%>common/uploadify32/jquery.uploadify.min.js'></script>

<link rel="stylesheet" type="text/css" href="<%=basePath %>app/css/layout.css" />
<script  src="<%=basePath %>common/javascript/common.js"></script>
<script src='<%=basePath%>thirtpart/jquery/jquery.blockUI.js'></script>



<style>.tac{text-align:center}</style>
<script>
$(document).ready(function() {
  
 $('#pdf_upload').uploadify({
    'buttonText'    :   '请选择文件', 
    'swf'  :  '<%=basePath%>common/uploadify32/uploadify.swf',
    'uploader'  : '<%=basePath %>data/mod/pdfupload.do', 
    'cancelImg' : '<%=basePath%>common/uploadify/cancel.png',
    'folder'    : '<%=basePath%>upload',
    'queueID'   : 'fileQueue_pdf',
    'fileObjName':'pdffile',
    'auto'      : false,
     'multi': false, 
    'method'         : 'GET', 
	'buttonImg' : '<%=basePath%>common/uploadify32/selectfile.gif',  
	'fileTypeExts'        : '*.pdf',   
    'fileDesc'       : '请选择PDF文件(*.pdf)', 
     onSelect : function(event,queueId,fileObj,data){
    	var idselectedstr = window.parent.magalist.getSelectPaper();
    	var selectedId = "";  
    	if(idselectedstr == ""){
	    	alert("请先选择要上传原文的文献!"); 
	    	$('#fileQueue_pdf').uploadify('cancel'); 
	    	return;
	    }else{
	    	var temp = idselectedstr.split(','); 
	    	if(temp.length>2){
	    		alert("只能选择一篇文献上传原文!"); 
	    		$('#fileQueue_pdf').uploadify('cancel'); 
	    		return; 
	    	} 
	    }     
	      
    },
    onUploadStart : function() { 
         var idselectedstr = window.parent.magalist.getSelectPaper();
         var temp = idselectedstr.split(','); 
         var selectedId = idselectedstr.substr(0,idselectedstr.length-1);
 	     document.getElementById("paperid").value=selectedId; 
	     //alert($('#paperid').val());
	     $('#pdf_upload').uploadify('settings','formData',{'paperid':$('#paperid').val()});  
         $.blockUI();  
         
     },
    onUploadSuccess: function (file, response, data) {
   		 $.unblockUI();
   		 //$('#uploader_pdf').text(response); 
   		 alert(response);
   		 //window.parent.booklist.frameElement.src = "<%=basePath%>data/bookList.do"; 	
   		 window.parent.magalist.displayAttchImg($('#paperid').val());
    },
   	onUploadError: function(event, queueID, fileObj,info) { 
   	    $.unblockUI();     
		alert("数据上传失败！");
    },
    onOpen  : function(event,ID,fileObj) {
       
    } 
    
  });
});
 
 </script>
</head>
<body>
<div class="contlist"> 
<div class="listWrap">
 
	    <table width="99%" border="0" cellspacing="0" cellpadding="0" class="tableList">
      <tr>
        <th   style="text-align:center;  font-size:16px;">文献原文上传</th>
      </tr>
      <tr>
      	<td>
      		<div id="fileQueue_pdf" align="center"> 
              <input id="pdf_upload" name="pdf_upload" type="file" />	&nbsp;&nbsp;
              <input id="paperid" name="paperid" type="hidden" value="" />	&nbsp;&nbsp;
              <input type="button" onclick="jQuery('#pdf_upload').uploadify('upload','*')" value="开始上传" class="btn btn-primary"/> 
              <input type="button" onclick="jQuery('#pdf_upload').uploadify('cancel')" value="取消上传" class="btn btn-primary"/>
            </div>
      	</td>
      	</tr>
      	<tr>
      	<td>
      		<font color=red>操作说明：</font><br>
      		上传原文附件时，请先在左侧数据列表选择原文对应的条目，具体操作步骤如下:</br>
      		<br>
      		1、选择要上传附件的条目;</br>
      		<br>
      		2、选择要传的原文;</br>
      		<br>
      		3、上传;</br>
      	</td>
      </tr>
    </table>
    </div>
    </div>
</body>
</html>
